%% Plot violin (swarm) distributions of each experiment
close all;

%% Load data
dirnames = struct();
% Directory name
dirnames(1).name = "/Users/bknapp/Documents/FRAP_Data/221102_mitotracker_FRAP/bw25113_pad_2/matlab_structs/";
dirnames(2).name = "/Users/bknapp/Documents/FRAP_Data/20221103_mitotracker_FRAP/BW25113_LB_37C/matlab_structs/";
dirnames(3).name = "/Users/bknapp/Documents/FRAP_Data/221102_mitotracker_FRAP/fabR/matlab_structs/";
dirnames(4).name = "/Users/bknapp/Documents/FRAP_Data/221102_mitotracker_FRAP/fadR/matlab_structs/";
dirnames(5).name = "/Users/bknapp/Documents/FRAP_Data/20221103_mitotracker_FRAP/BW_LB_triclosan5ngmL_37C/matlab_structs/";
dirnames(6).name = "/Users/bknapp/Documents/FRAP_Data/20221103_mitotracker_FRAP/BW_LB_27to37C/matlab_structs/";
dirnames(7).name = "/Users/bknapp/Documents/FRAP_Data/20221103_mitotracker_FRAP/MG1655_LB_37C/matlab_structs/";

% Matlab file to load
fname = "FRAP_struct_corrected.mat"; 

%% Load and plot
plotcolors = [0 0 255; 0 0 255; 0 0 0; 255 0 0; 105 216 122; 218, 112, 234; 88, 126, 228]/255


viscosity_struct = struct();
figure;
for k=1:length(dirnames)
    dirname = dirnames(k).name;
    load(strcat(dirname,fname));
    % Rename for analysis
    tempstruct = FRAP_struct_corrected;

    eta_all_plot = [tempstruct.eta]';
    viscosity_struct(k).eta = eta_all_plot;


    xplot = k*ones(1,length(eta_all_plot))';

    swarmchart(xplot, eta_all_plot, 50, 'filled', 'markerfacecolor', plotcolors(k,:));
    hold on;
end

set(gca, 'FontSize', 20);
set(gca, 'FontName', 'Arial');
set(gcf, "Position", [500 500 600 300]);
xlabel('Condition')
ylabel('Viscosity (P)')

%% Combine wild-type BW plots and plot against mutants
BWtot  = [viscosity_struct(1).eta; viscosity_struct(2).eta];
xplot_BW = ones(length(BWtot));
fabR = viscosity_struct(3).eta;
fadR = viscosity_struct(4).eta;

figure;
swarmchart(ones(length(BWtot)), BWtot, 50, 'filled', 'markerfacecolor', 'b');
hold on;
swarmchart(2*ones(length(fabR)), fabR, 50, 'filled', 'markerfacecolor', 'k');
swarmchart(3*ones(length(fadR)), fadR, 50, 'filled', 'markerfacecolor', 'r');
set(gca, 'FontSize', 20);
set(gca, 'FontName', 'Arial');
set(gcf, "Position", [500 500 400 300]);
xlabel('Condition');
ylabel('Viscosity (P)');